package com.googlecode.dgwt.client.dojox.data.base;

import java.util.Collection;

import com.googlecode.dgwt.client.dojo.data.base.TableStoreBase;
import com.googlecode.dgwt.client.dojo.data.model.StoreModel;
import com.googlecode.dgwt.client.dojox.data.model.ProxyModel;
import com.googlecode.dgwt.client.dojox.data.model.base.GridColumn;
import com.googlecode.dgwt.client.dojox.data.model.base.GridModel;


/**
 * @author      Wellington Tadeu dos Santos
 * @since       DGWT v0.01
 */
public abstract class DataStoreBase<Item, Model extends GridModel<Item,Column>,Column extends GridColumn<Item, ?>> extends TableStoreBase<Item,Model,Column> implements GridStore<Item> {

    protected DataStoreBase() {
        super();
    }

    protected DataStoreBase(Collection<Item> items) {
        super(items);
    }

    protected DataStoreBase(int initialCapacity) {
        super(initialCapacity);
    }

    protected DataStoreBase(DataStoreBase<Item, Model, Column> mirroredStore, Model newModel) {
        super(mirroredStore, newModel);
    }
    

    public DataStoreBase(Model model, Collection<? extends Item> items) {
        super(model, items);
    }

    public DataStoreBase(Model model, int initialCapacity) {
        super(model, initialCapacity);
    }

    public DataStoreBase(Model model) {
        super(model);
    }

    @Override
    public int getColumnMaxLength(int columnIndex) {
        return getModel().getColumns().get(columnIndex).getMaxLength();
    }

    @Override
    protected boolean isModelCompatible(StoreModel<?, ?> model) {
        return super.isModelCompatible(model) || model instanceof ProxyModel<?>;
    }

    @Override
    public void setReadOnly(boolean readOnly) {
        super.setReadOnly(readOnly);
    }

}
